package com.itboye.zhujia.adapter.key;

import java.util.List;
import java.util.Map;

import com.itboye.zhujia.R;
import com.itboye.zhujia.adapter.key.ItemUnlockingAdapter.ViewHolder;
import com.itboye.zhujia.custom.RoundImageView;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;
/**
 * 用户管理适配器
 *
 */
public class ItemUserManAdapter extends BaseAdapter {
	private Context context;
	private List<Map<String, Object>> list;
	
	public ItemUserManAdapter(Context context,List<Map<String, Object>> list) {
		this.context=context;
		this.list=list;
	}

	@Override
	public int getCount() {
		return list.size();
	}

	@Override
	public Object getItem(int position) {
		return list.get(position);
	}

	@Override
	public long getItemId(int position) {
		return position;
	}

	@Override
	public View getView(int position, View view, ViewGroup parent) {
		ViewHolder holder;
		
		if(view==null){
			view=LayoutInflater.from(context).inflate(R.layout.item_user_mangment, null);
			holder=new ViewHolder();
			holder.user_image=(RoundImageView) view.findViewById(R.id.user_image);
			holder.user_tel=(TextView) view.findViewById(R.id.user_tel);
			holder.user_key=(TextView) view.findViewById(R.id.user_key);
			holder.user_type=(TextView) view.findViewById(R.id.user_type);
			
			view.setTag(holder);
		}else{
			holder=(ViewHolder) view.getTag();
		}
		
		//List<Map<String,Object>>的时候用这个
		holder.user_image.setBackgroundResource(Integer.valueOf(list.get(position).get("img").toString()));
		holder.user_tel.setText(list.get(position).get("name").toString());
		holder.user_key.setText(list.get(position).get("state").toString());
		holder.user_type.setText(list.get(position).get("time").toString());
		
		return view;
	}
	class ViewHolder{
		RoundImageView user_image;
		TextView user_tel;
		TextView user_key;
		TextView user_type;
	}
}
